package com.yx.backstage.util;

import com.yx.backstage.manager.FileTypeManager;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Set;

/**
 * @author YangXiong
 */
@Component
@Slf4j
public class FileTypeUtil {

    @Resource
    private FileTypeManager fileTypeManager;

    public String isOneType(String typeString) {
        Set<String> allKind = fileTypeManager.getAllKind();
        for (String one : allKind) {
            Set<String> type = fileTypeManager.getTypeListByKind(one);;
            log.info("kind===={}", one);
            for (String oneType : type) {
                log.info("type===={}", oneType);
                if (StringUtils.equals(typeString, oneType)) {
                    return one;
                }
            }
        }
        return "error";
    }
}
